//
//  LYBaseTableViewController.swift
//  Sina_Weibo2
//
//  Created by Elsevier on 16/5/11.
//  Copyright © 2016年 Yang Lu. All rights reserved.
//

import UIKit

class LYBaseTableViewController: UITableViewController {
    
    var userLogin:Bool = false
    
    override func loadView() {
        if userLogin  {
            super.loadView()
        } else {
            view = visitorView
            
            visitorView.delegate = self
            
            if self is LYHomeViewController{
                visitorView.startRotationAnimation()
            }else if self is LYMessageViewController{
                visitorView.setupVisitorInfo("visitordiscover_image_ message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            }else if self is LYDiscoveryViewController{
                visitorView.setupVisitorInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            }else if self is LYProfileViewController{
                visitorView.setupVisitorInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
            }
            
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
        }
    }
    
    // MARK : - 懒加载
    private lazy var visitorView:LYVisitorView = LYVisitorView()
}

//MARK : - 扩展: 协议
extension LYBaseTableViewController: LYVistorViewDelegate {
            func visitorViewDidClickRegister() {
                print(__FUNCTION__)
            }
    
            func visitorViewDidClickLogin() {
                let oauthVC = LYOauthViewController()
                let nav = UINavigationController(rootViewController: oauthVC)
                
                self.presentViewController(nav, animated: true, completion: nil)
            }
}